#ifndef C_GENERATE_TYPE_C__
#define C_GENERATE_TYPE_C__

char* c$generateType(struct Type* t)
{
	char* i;
	char* r;

	switch(t->tag)
	{
		case CHAR:
			return "char";
		case INT:
			return "int32_t";
		case VOID:
			return "void";
		case ENUM:
			i = c$generateName(t->internal);
			r = malloc(strlen(i) + 6);
			sprintf(r,"enum %s",i);
			return r;
		case STRUCT:
			i = c$generateName(t->internal);
			r = malloc(strlen(i) + 8);
			sprintf(r,"struct %s",i);
			return r;
		case UNION:
			i = c$generateName(t->internal);
			r = malloc(strlen(i) + 7);
			sprintf(r,"union %s",i);
			return r;
		case POINTER:
			i = c$generateType(t->internal);
			r = malloc(strlen(i) + 2);
			sprintf(r,"%s*",i);
			return r;
		default:
			assert(0); // Should never happen.
	}
}

#endif
